<template>
<view class="page detail div">
  <view class="page__bd div">
    <view class="weui-tab div">
      <view class="weui-tab__panel div">
        <view class="title div">
          <text> {{activity.title}} </text>
        </view>
        <view class="summary div">
          <text> <text class="text-success">[活动每人收取<text>10</text>元费用，联系活动发布人线下支付]</text>{{activity.description}} </text>
        </view>
        <view class="weui-panel weui-panel_access div">
          <view class="weui-panel__bd div">
            <view class="author div">
              <image :src="activity.organizer_avatar" alt class="avatar img"></image>
              <view class="nickname span">
                <text>{{activity.organizer_nickname}}</text>
              </view>
              <view class="tag span">
                <text>发起人</text>
              </view>
            </view>
            <view class="list div">
              <view class="item div">
                <view class="name div">
                  <text>报名截止时间</text>
                </view>
                <view class="time div">
                  <text>{{activity.join_deadline_date}}</text>
                </view>
              </view>
            </view>
			<block v-if="activity.join_total > 0">
            <view class="join-num div">
              <view class="pull-right div">
                <view class="count">
                  <image src="" class="icon"></image>
                  <text class="num">
                    {{activity.join_total}}人
                  </text>
                </view>
                <view class="count">
                  <image src="" class="icon"></image>
                  <text class="num">
                    {{activity.join_total}}人
                  </text>
                </view>
              </view>
              <text> 活动参与 </text>
            </view>
            <view class="list-applicant">
              <view v-for="(item, index) in activity.join_list" :key="index" class="item">
                <image :src="item.avatar" alt class="weui-media-box__thumb avatar"></image>
                <view class="info">
                  <view class="nickname">
                    {{item.remark}}
                    <text class="time"> {{item.join_date}} </text>
                  </view>
                  <view class="message">
                    <view class="message-content">
                      无留言
                    </view>
                    <view class="participant-info">
                      <text class="username">李雷</text>
                      <text class="tel">18812345678</text>
                      <text class="empty">该用户已设置身份信息只对发布者可见</text>
                    </view>
                  </view>
                </view>
               </view>
              </view>


            <!--<view class="weui-panel__bd list-applicant">
              <view class="weui-media-box weui-media-box_appmsg" wx:for="{{activity.join_list}}">
                <view class="weui-media-box__hd">
                  <image src="{{item.avatar}}" alt="" class="weui-media-box__thumb avatar"></image>
                </view>
                <view class="weui-media-box__bd">
                  <view class="weui-media-box__title">
                    {{item.remark}}
                    <text class="pull-right"> {{item.join_date}} </text>
                  </view>
                  <view class="weui-media-box__desc">
                    <view class="message">
                      <view class="message-content">
                        无留言
                      </view>
                      <view class="participant-info">
                        <text class="empty">该用户已设置身份信息只对发布者可见</text>
                      </view>
                    </view>
                  </view>
                </view>
              </view>
            </view>-->
			</block>
            <view class="share-tips div" v-if="activity.join_total == 0">
              <view class="name div">
                <text>赶快分享活动给大家</text>
              </view>
              <view class="tips div">
                <view class="div">
                  <text>方式一：点击右上角 "..." ，分享到群！</text>
                </view>
                <view class="div">
                  <text>方式二：点击下图“保存图片”，分享到朋友圈。</text>
                </view>
              </view>
              <view class="text-center div">
                <text>{{activity.title}}</text>
              </view>
              <view class="qr div">
                <image :src="activity.code" @tap="onPreviewImage" :data-preview="activity.code" alt class="img-qr img"></image>
              </view>
            </view>
          </view>
        </view>
      </view>
    </view>
	<block data-src="../common/footer.wxml"><view class="weui-tabbar div">
	<view class="weui-tabbar__item btn-mine a">
		<view class="weui-tabbar__label p">
			<navigator url="/rcdonkey_signup/pages/index/index" open-type="redirect" hover-class="other-navigator-hover">我的</navigator>
		</view>
	</view>
	<view class="weui-tabbar__item btn-publish a">
		<view class="weui-tabbar__label p">
			<navigator url="/rcdonkey_signup/pages/publish/publish" open-type="navigate" hover-class="other-navigator-hover">发布</navigator>
		</view>
	</view>
	<block v-if="activity.status == 3">
		<view class="weui-tabbar__item btn-share a">
			<view class="weui-tabbar__label p">
				<text>已结束</text>
			</view>
		</view>
	</block>
	<block v-if="activity.status != 3">

		<view class="weui-tabbar__item btn-share a" v-if="activity.is_manager || activity.already_join">
			<view class="weui-tabbar__label p">
				<navigator :url="'/rcdonkey_signup/pages/share/share?id=' + activity.id" open-type="navigate" hover-class="other-navigator-hover">我要分享</navigator>
			</view>
		</view>
		<view class="weui-tabbar__item btn-sign-up a" v-else="!activity.is_manager">
			<view class="weui-tabbar__label p">
				<navigator :url="'/rcdonkey_signup/pages/sign-up/sign-up?id=' + activity.id" open-type="navigate" hover-class="other-navigator-hover"><text>我要报名</text></navigator>
			</view>
		</view>
	</block>
</view></block>
  </view>
</view>
</template>

<script>
var app = getApp();

export default {
  data() {
    return {
      activity: {},
      session: ""
    };
  },

  components: {},
  props: {},
  onLoad: function (request) {
    var $this = this;

    if (request.id) {
      app.globalData.util.request({
        url: 'entry/wxapp/detail',
        data: {
          m: 'rcdonkey_signup',
          id: request.id
        },
        method: 'post',
        success: function (response) {
          $this.setData({
            'activity': response.data.data
          });
        }
      });
    }
  },
  onReady: function () {
    var $this = this;
    app.globalData.util.getUserInfo(function (response) {
      $this.setData({
        session: response
      });
    });
  },
  onPullDownRefresh: function () {
    var $this = this;
    app.globalData.util.request({
      url: 'entry/wxapp/detail',
      data: {
        m: 'rcdonkey_signup',
        id: $this.data.activity.id
      },
      method: 'post',
      success: function (response) {
        $this.setData({
          activity: []
        });
        $this.setData({
          'activity': response.data.data
        });
        wx.stopPullDownRefresh();
      }
    });
  },
  onShareAppMessage: function () {
    var $this = this;
    return {
      title: $this.data.activity.title,
      path: '/rcdonkey_signup/pages/detail/detail?id=' + $this.data.activity.id,
      success: function (res) {}
    };
  },
  methods: {
    onJoin: function () {
      var $this = this;

      if (!$this.data.activity) {
        app.globalData.util.message({
          title: '活动不存在或是已经被删除',
          redirect: 'redirect:/rcdonkey_signup/pages/index/index'
        });
      }

      app.globalData.util.request({
        url: 'entry/wxapp/join',
        data: {
          m: 'rcdonkey_signup',
          id: $this.data.activity.id
        },
        method: 'post',
        success: function (response) {
          if (response.data.errno) {
            app.globalData.util.message({
              title: response.data.message,
              type: 'error',
              redirect: response.data.data.redirect
            });
          } else {
            app.globalData.util.message({
              title: '报名成功',
              redirect: 'redirect:/rcdonkey_signup/pages/detail/detail?id=' + $this.data.activity.id
            });
          }
        }
      });
    },
    onPreviewImage: function (event) {
      app.globalData.util.showImage(event);
    }
  }
};
</script>
<style>
@import "./detail.css";
</style>